package com.yidiandao.business.ui.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 发现每个分类下的子adapter
 * <p>
 * Created by SunDing(dindding@163.com) on 2017/4/12 14:05
 */
public class DiscoveryItemPageAdapter extends FragmentPagerAdapter {

    private List<Fragment> mFragments = new ArrayList<>();

    private List<String> mTitleList = new ArrayList<>();

    public DiscoveryItemPageAdapter(FragmentManager fm) {
        super(fm);
        mFragments.clear();
        mTitleList.clear();
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    public void addFragment(Fragment fragment) {
        mFragments.add(fragment);
    }

    public void addTitle(String title) {
        mTitleList.add(title);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitleList.get(position);
    }
}
